#include "../inc/Chess/elephant.h"
#include <iostream>
using namespace std;

Elephant::Elephant(PieceType type, int row, int col, bool isRed)
    : Piece(type, row, col, isRed), hasElephantEyeBlocked(false)
{
}

bool Elephant::is_valid_move(int to_row, int to_col, PieceType board[9][10])
{
    int row = position.first;
    int col = position.second;

    // 计算移动距离
    int row_diff = to_row - row;
    int col_diff = to_col - col;

    // 象走田字
    if (!(abs(row_diff) == 2 && abs(col_diff) == 2))
    {
        return false;
    }
    
    if (abs(row_diff) == 2 && abs(col_diff) == 2)
    {
        int eye_row = row + row_diff / 2;
        int eye_col = col + col_diff / 2;
        if (board[eye_row][eye_col] != PieceType::kong)
        {
            cout << "象眼被堵" << endl;
            return false;
        }
    }
    return true;
}